/**
 * BoardDaoImpl.java 1.0 2007-5-15 上午01:04:58,创建 by yangfan
 */


package org.in4j.bbs.dao.hbm;

import java.util.List;

import org.in4j.bbs.dao.BoardDao;
import org.in4j.bbs.model.Board;
import org.in4j.core.dao.AbstractHibernateDao;

/**
 *
 * @author yangfan
 * @version 1.0 2007-5-15 上午01:04:58,创建
 */
public class BoardDaoImpl extends AbstractHibernateDao<Board> implements BoardDao
{
	public Board getBoardByName(String boardName, boolean initTopics)
	{
		List<Board> boards = super.find("from Board where name=?", boardName);
		if(boards.isEmpty())
			return null;
		Board board = boards.iterator().next();
		if(initTopics)
		{
			System.out.println("initialize topics...");
			getHibernateTemplate().initialize(board.getGlobalPinedTopics());
			getHibernateTemplate().initialize(board.getPinedTopics());
		}
		return board;
	}
}
